//
//  ProductDetailViewController.m
//  SimpleTimeDemo
//
//  Created by lanou3g on 15/11/18.
//  Copyright © 2015年 王丽珍. All rights reserved.
//

#import "ProductDetailViewController.h"
#import "MainDataHelper.h"
#import "ProductModel.h"
@interface ProductDetailViewController ()

@property (nonatomic, strong) UIWebView *webView;

@end

@implementation ProductDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self loadWebView];
}

- (void)loadWebView{
    _webView = [[UIWebView alloc] initWithFrame:self.view.frame];
    
    [self.view addSubview:_webView];
    
    NSString *string = @"http://api2.pianke.me/group/posts_info";
    NSString *bodyString = [NSString stringWithFormat:@"auth=&client=1&contentid=%@&deviceid=2AD5AE2D-2FE5-4DF7-AB1E-150BCF01269E&version=3.0.6",_conStr];
    [MainDataHelper postDataWithUrlString:string andBodyString:bodyString compare:^(id object) {
        NSDictionary *dic = object;
        ProductModel *model = [[ProductModel alloc] init];
        model.html = dic[@"data"][@"postsinfo"][@"html"];
        
        [_webView loadHTMLString:model.html baseURL:nil];
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
